package com.eedi.org.hospital.controller;

import cn.hutool.core.lang.Assert;
import com.eedi.framework.common.pojo.CommonResult;
import com.eedi.framework.hospdept.core.HospStandardDept;
import com.eedi.org.hospital.convert.OrgHospStandardDeptConvert;
import com.eedi.org.hospital.controller.vo.standarddept.OrgStandardDeptNodeRespVO;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.eedi.framework.hospdept.core.utils.HospDeptUtils;
import java.util.List;

import static com.eedi.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 标准科室")
@RestController
@RequestMapping("/hosp-standard-dept")
@Validated
public class OrgHospStandardDeptController {

    @GetMapping("/tree")
    public CommonResult<List<OrgStandardDeptNodeRespVO>> getHospStandardTree() {
        HospStandardDept hospDept = HospDeptUtils.getDept(HospStandardDept.CLINIC_DEPT);
        Assert.notNull(hospDept, "获取不到科室");
        return success(OrgHospStandardDeptConvert.INSTANCE.convertList(hospDept.getChildren()));
    }

}
